#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>

typedef struct {
    int argc;
    void* argv;
    void (*job_func)(int, void*);
} Job;

static void do_job(int argc, void* argv)
{
    int i = 5;
    printf("do_job: %d --> %s...\n", argc, (char*)argv);

    while (i-- > 0) {
        sleep(1);
    }
}

static Job g_job[] = {
    {1, "Delphi", do_job},
    {2, "D.T.Software", do_job},
    {3, "Tang", do_job},
};

static const int g_jlen = sizeof(g_job) / sizeof(*g_job);

static siginfo_t g_sig_arr[65] = {0};
static const int g_slen = sizeof(g_sig_arr) / sizeof(*g_sig_arr);

static void mask_all_signal()
{
    sigset_t set = {0};

    sigfillset(&set);
    sigprocmask(SIG_SETMASK, &set, NULL);
}

int main(int argc, char* argv[])
{
    int i = 0;
    
    mask_all_signal();

    printf("current pid(%d) ...\n", getpid());

    while (i < g_jlen) {
        int argc = g_job[i].argc;
        char* argv = g_job[i].argv;

        g_job[i].job_func(argc, argv);
        
        i++;
    }

    return 0;
}
